package com.komodo.island.gdx.screen;

import java.util.ArrayList;
import java.util.List;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.komodo.island.gdx.ChatBox;
import com.komodo.island.gdx.GameDescription;
import com.komodo.island.gdx.KomodoIsland;
import com.komodo.island.gdx.dialog.Dialog;
import com.komodo.island.gdx.dialog.MapDialog;

public class MapScreen extends Screen {

	public static final int SUIT = 1;
	public static final int PHOTO = 2;
	public static final int UNDERWATER = 5;
	public static final int BALANCE = 0;
	public static final int CASTLE = 4;
	public static final int MOVE = 3;
	public static final int SHOPPING = 6;

	// public ChatBox chatBox ;
	// public boolean isChatAvailable = true;
	public MapDialog mapDialog;

	public boolean gameDescShow = false;

	// public List<ChatBox> dialogChat;

	public TextureRegion gameDesc[];
	public int chosenGame;
	public GameDescription gameDescDialog;

	@Override
	public void init(KomodoIsland komodoIsland, Texture texture) {
		// TODO Auto-generated method stub
		super.init(komodoIsland, texture);
		previousScreen = komodoIsland.playerScreen;

		// List<String> text = new ArrayList<String>();

		// text.add("hai tono");

		// chatBox = new ChatBox(text);

		// gameDesc = new TextureRegion[7];
		// gameDesc[SUIT] = new TextureRegion(texture, 0, 0, 480, 320);
		// gameDesc[CASTLE] = new TextureRegion(texture, 0, 0, 480, 320);
		// gameDesc[BALANCE] = new TextureRegion(texture, 0, 0, 480, 320);
		// gameDesc[MOVE] = new TextureRegion(texture, 0, 0, 480, 320);
		// gameDesc[PHOTO] = new TextureRegion(texture, 0, 0, 480, 320);
		// gameDesc[SHOPPING] = new TextureRegion(texture, 0, 0, 480, 320);
		// gameDesc[CASTLE] = new TextureRegion(texture, 0, 0, 480, 320);

	}

	@Override
	public void onScreenRun() {
		// TODO Auto-generated method stub
		if (gameDescShow) {
			gameDescDialog.draw();
		} else {
			mapDialog.draw();
		}

		// if (isChatAvailable){
		// chatBox.draw();
		// if (Gdx.input.justTouched()){
		// // chatBox.chat();
		// }
		// }
	}

	@Override
	public void onScreenLoading() {
		// TODO Auto-generated method stub

	}

	@Override
	public void setScreenToRun() {
		// TODO Auto-generated method stub
		setCameraToDefault();
		screenState = RUNNING;
		komodoIsland.input.setStage(mapDialog);
	}

	public void showGameDesc(int gameIndex) {
		gameDescShow = true;
		komodoIsland.input.setStage(gameDescDialog);
		gameDescDialog.setChoise(gameIndex);
	}

	public void hideGameDesc() {
		gameDescShow = false;
		komodoIsland.input.setStage(mapDialog);
	}

	@Override
	public void dispose() {
		// TODO Auto-generated method stub
		super.dispose();

	}

	@Override
	public void cleanResScreen() {
		// TODO Auto-generated method stub
		super.cleanResScreen();
		try {
			gameDescDialog.dispose();
			mapDialog.dispose();
		} catch (Exception e) {

		}
	}

	@Override
	public void show() {
		// TODO Auto-generated method stub
		super.show();
		mapDialog.addElements();
	}
}
